import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;

public class HJ19 {
    public static void main(String[] arr) {
        Scanner sc = new Scanner(System.in);
        //key:文件名 行数   value:条数
        Map<String, Integer> map = new LinkedHashMap<>();
        //循环读入数据
        while(sc.hasNext()){
            String str = sc.nextLine();
            String[] strs = str.split(" ");
            //文件名
            String fileName = strs[0].substring(strs[0].lastIndexOf("\\")+1);
            //行号
            String no = strs[1];
            //超过16个字符的文件名称，只记录文件的最后有效16个字符
            if(fileName.length() > 16) {
                fileName = fileName.substring(fileName.length() - 16);
            }

            //存入map
            String key = fileName + " " + no;
            int value = 1;
            if(map.containsKey(key)) {
                map.put(key, map.get(key)+1);
            } else {
                map.put(key, value);
            }
        }

        int count = 0;
        for (String key: map.keySet()) {
            count ++;
            if (count > (map.size()-8)) {
                //循环记录，输出最后8条
                System.out.println(key+" "+map.get(key));
            }
        }
    }
}
